package com.dindang.maintenance.mvp.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.constraint.ConstraintLayout;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.dindang.maintenance.R;
import com.dindang.maintenance.di.component.DaggerMaintainDetailsComponent;
import com.dindang.maintenance.di.module.MaintainDetailsModule;
import com.dindang.maintenance.mvp.contract.MaintainDetailsContract;
import com.dindang.maintenance.mvp.presenter.MaintainDetailsPresenter;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;

import static com.jess.arms.utils.Preconditions.checkNotNull;

@Route(path = "/maintenance/activity/MaintainDetailsActivity")
public class MaintainDetailsActivity extends BaseActivity<MaintainDetailsPresenter> implements MaintainDetailsContract.View {

    ImageView mIvBack;
    TextView mTvTitle;
    RecyclerView mRvImage;
    ImageView mIvToRight;
    RecyclerView mRvProgress;
    ConstraintLayout mConstraintlayout;
    TextView mTvSendOrder;
    TextView mTvPlan;
    TextView mTvProgress;
    TextView mTvUndo;

    TextView mTvState;
    TextView mTvOrdernoValue;
    TextView mTvRepairAreaValue;
    TextView mTvRepairManValue;
    TextView mTvRepairManLabel;
    ImageView mIvPhone;
    TextView mTvRepairTimeValue;
    TextView mTvAppointmentTimeValue;
    TextView mTvProjectNameValue;
    TextView mTvPresentTimeValue;
    TextView mTvRepairTypeValue;
    TextView mTvFaultTypesValue;
    TextView mTvFaultDescriptionValue;


    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerMaintainDetailsComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .maintainDetailsModule(new MaintainDetailsModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.maintenance_activity_maintain_details; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        mIvBack = findViewById(R.id.maintenance_iv_back);
        mTvTitle = findViewById(R.id.maintenance_tv_title);
        mRvImage = findViewById(R.id.maintenance_rv_image);
        mRvImage.setNestedScrollingEnabled(false);
        mRvImage.setFocusable(false);
        mIvToRight = findViewById(R.id.maintenance_iv_to_right);

        mRvProgress = findViewById(R.id.maintenance_rv_progress);
        mRvProgress.setNestedScrollingEnabled(false);
        mRvProgress.setFocusable(false);

        mConstraintlayout = findViewById(R.id.maintenance_constraintlayout);
        mTvPlan = findViewById(R.id.maintenance_tv_plan);
        mTvSendOrder = findViewById(R.id.maintenance_tv_send_order);
        mTvProgress = findViewById(R.id.maintenance_tv_progress);
        mTvUndo = findViewById(R.id.maintenance_tv_undo);

        mTvState = findViewById(R.id.maintenance_tv_state);
        mTvOrdernoValue = findViewById(R.id.maintenance_tv_orderno_value);
        mTvRepairAreaValue = findViewById(R.id.maintenance_tv_repair_area_value);
        mTvRepairManValue = findViewById(R.id.maintenance_tv_repair_man_value);
        mTvRepairManLabel = findViewById(R.id.maintenance_tv_repair_man_label);
        mIvPhone = findViewById(R.id.maintenance_iv_phone);
        mTvRepairTimeValue = findViewById(R.id.maintenance_tv_repair_time_value);
        mTvAppointmentTimeValue = findViewById(R.id.maintenance_tv_appointment_time_value);
        mTvProjectNameValue = findViewById(R.id.maintenance_tv_project_name_value);
        mTvPresentTimeValue = findViewById(R.id.maintenance_tv_present_time_value);
        mTvRepairTypeValue = findViewById(R.id.maintenance_tv_repair_type_value);
        mTvFaultTypesValue = findViewById(R.id.maintenance_tv_fault_types_value);
        mTvFaultDescriptionValue = findViewById(R.id.maintenance_tv_fault_description_value);

        mTvTitle.setText("维修详情");
        mTvTitle.setOnClickListener(v -> finish());
        mIvBack.setOnClickListener(v -> finish());

        mPresenter.init();
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    @Override
    public RecyclerView getRvImage() {
        return mRvImage;
    }

    @Override
    public ImageView getIvToRight() {
        return mIvToRight;
    }

    @Override
    public RecyclerView getRvProgress() {
        return mRvProgress;
    }

    @Override
    public ConstraintLayout getConstraintlayout() {
        return mConstraintlayout;
    }

    @Override
    public TextView getTvPlan() {
        return mTvPlan;
    }

    @Override
    public TextView getTvSendOrder() {
        return mTvSendOrder;
    }

    @Override
    public TextView getTvProgress() {
        return mTvProgress;
    }

    @Override
    public TextView getTvUndo() {
        return mTvUndo;
    }

    @Override
    public TextView getTvState() {
        return mTvState;
    }

    @Override
    public TextView getTvOrdernoValue() {
        return mTvOrdernoValue;
    }

    @Override
    public TextView getTvRepairAreaValue() {
        return mTvRepairAreaValue;
    }

    @Override
    public TextView getTvRepairManValue() {
        return mTvRepairManValue;
    }

    @Override
    public TextView getTvRepairManLabel() {
        return mTvRepairManLabel;
    }

    @Override
    public ImageView getIvPhone() {
        return mIvPhone;
    }

    @Override
    public TextView getTvRepairTimeValue() {
        return mTvRepairTimeValue;
    }

    @Override
    public TextView getTvAppointmentTimeValue() {
        return mTvAppointmentTimeValue;
    }

    @Override
    public TextView getTvProjectNameValue() {
        return mTvProjectNameValue;
    }

    @Override
    public TextView getTvPresentTimeValue() {
        return mTvPresentTimeValue;
    }

    @Override
    public TextView getTvRepairTypeValue() {
        return mTvRepairTypeValue;
    }

    @Override
    public TextView getTvFaultTypesValue() {
        return mTvFaultTypesValue;
    }

    @Override
    public TextView getTvFaultDescriptionValue() {
        return mTvFaultDescriptionValue;
    }

    @Override
    public BaseActivity getActivity() {
        return this;
    }
}
